<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    	<meta name="format-detection" content="telephone=no">
		<title>关注公众号</title>
		<link rel="stylesheet" href="../css/app-h5-common.css" />
		<script type="text/javascript" src="../js/jquery.min.js" ></script>
		<script type="text/javascript" src="../js/iscroll.min.js" ></script>
	</head>
	<style>
		html{
			font-size: 100px;
			background: #FFFFFF;
		}
		body{
			width: 100%;
		}
		.header{
			width: 100%;
			margin-bottom: 0.2rem;
			
		}
		.header img{
			display: block;
			width: 100%;
		}
		.content{
			width: 100%;
			padding: 0 0.15rem 0.3rem;
			box-sizing: border-box;
			color: #212a2f;
			font-size: 0.16rem;
			position: relative;
		/*	margin-bottom: 0.6rem;*/
			
		}
		.zan{
			position: absolute;
			right: 0.15rem;
			color: #F45440;
			
		}
		.zan .zanImg{
			display: inline-block;
			width: 0.16rem;
			height: 0.15rem;
			margin-right: 0.05rem;
			float: left;
		}
		.title{
			font-size: 0.24rem;
			font-weight: bold;
			line-height: 0.31rem;
			width: 2.4rem;
			overflow: auto;
			margin-bottom: 0.2rem;

		}
		.abstract{
			font-size: 0.14rem;
			line-height: 0.2rem;
			margin-bottom:0.2rem
		}
		.source{
			font-size: 0.1rem;
			color: #aaaaaa;
			margin-bottom: 0.3rem;
		}
		.line{
			width: 100%;
			height: 1px;
			background-color:#DDDDDD;
			display: block;
			margin-bottom: 0.3rem;
		}
		.taskTit,.taskDetail{
			font-size: 0.15rem;
			color: #212A2F;
			line-height: 0.24rem;
			margin-bottom: 0.15rem;
		}
		
	
		.mask{
			display: none;
			position: absolute;
			left: 0;top: 0;
			width: 100%;
			height: 100%;
			background-color: #000000;
			opacity: 0.4;
		}
		.bottom{
			width: 100%;
			height: 0.6rem;
			background-color: #252829;
			opacity: 0.9;
			overflow: auto;
			position: fixed;
			bottom: 0;
			z-index: 9;
				
		}
		.focuse{
			width: 75%;
			height: 0.4rem;
			background-color:#F45440;;
			color: #FFFFFF;
			font-size: 0.16rem;
			text-align: center;
			line-height: 0.4rem;
			margin: 0.1rem auto;
			border-radius: 0.06rem;
			
		}
		.notComplete{
			font-size: 0.16rem;
			font-weight: bold;
			width: 75%;
		    background: #FFFFFF;

		    display: none;
    		margin: 0.35rem auto;
    		position: absolute;
		    z-index: 99;
		    top: 1rem;
		    left: 0;
		    right: 0;
		    border-radius: 0.24rem;
		    text-align: center;
		    box-sizing: border-box;

			padding: 0.21rem 0 0 0;
		}
		.notComplete .nontitle{
			font-weight: bold;
			font-size: 0.16rem;
			margin-bottom: 0.12rem;
		}
		.notComplete .nondesc{
			font-weight: normal;
			font-size: 0.12rem;
			margin-bottom: 0.12rem;
		}
		.notComplete .nonknow{
			color:#007AFF;
			font-weight: bold;
			height: 0.5rem;
			line-height: 0.5rem;
		}
		.notComplete .line{
			margin-top: 0.24rem;
			margin-bottom: 0;
		}

		#wrapper{
			position: absolute;
			z-index: 1;
			top: 0;
			bottom: 0;
			left: 0;
			width: 100%;
			overflow: hidden;
		}
		
		.scroller {
			position: absolute;
			z-index: 1;
			-webkit-tap-highlight-color: rgba(0,0,0,0);
			width: 100%;
			-webkit-transform: translateZ(0);
			-moz-transform: translateZ(0);
			-ms-transform: translateZ(0);
			-o-transform: translateZ(0);
			transform: translateZ(0);
			-webkit-touch-callout: none;
			-webkit-user-select: none;
			-moz-user-select: none;
			-ms-user-select: none;
			user-select: none;
			-webkit-text-size-adjust: none;
			-moz-text-size-adjust: none;
			-ms-text-size-adjust: none;
			-o-text-size-adjust: none;
			text-size-adjust: none;
		}
	</style>
	<body onload="loaded()">
		<div id="wrapper">
			<div class="scroller">
				<div class="header"><img src=""/></div>	
				<div class="content">
					<div class="zan"><img class="zanImg" src="../img/gift.png"/> <span class="likes"></span></div>
					<div class="title">
						
					</div>
					<p class="abstract"></p>
					<p class="source"><span class="web">微信号：</span><span class="time"></span></p>
					<span class="line"></span>
					<p class="taskTit">任务详情：</p>
					<p class="taskDetail"></p>
					<img src="../img/example.png" />
					
				</div>
				
			<div class="mask"></div>
			<div class="notComplete">
					<p class="nontitle">已复制公众号</p>
					<p class="nontitle name"></p>
					<div class="line"></div>
					<p class="nonknow">我知道了</p>
			</div>
			
			
		</div>
		</div>
		
		<div class="bottom">
					<div class="focuse">
						关注公众号
					</div>
		</div>
		
	</body>
	<script>
		var myScroll,answer,responseData,back;

		function loaded () {
			myScroll = new IScroll('#wrapper');
			
		};		
		document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
		
		
		
		function setWidth(){
   			var $imgWidth = $('.header img').width();
	    	$('.header img').css({'height':$imgWidth/1.5});
//	    	console.log($imgWidth+"/"+($imgWidth/1.5))
   		};
   		
   		function taskAmount(){
   			var datas=getUrlValue();
   			$.ajax({
   				type:"get",
   				url:"/appApi/receiveTask",
//				url:"receiveTask.json",
   				data:{userId:datas.userid,taskId:datas.taskid},
   				async:false,
   				success:function(callback){
   					console.log(callback);
   					if (callback.code==0) {
   						console.log(0);
   						back=true;
   					} else{
   						console.log(1);
   						back=false;
   					}
   				}
   			});
   			
   			
   		};
   		function mask(){
   			var maxScrollY=myScroll.maxScrollY;
			myScroll.scrollTo(0,10,10);
			$(".mask").show();
			$(".notComplete").show();
			
   		}
   		function clickFocus(){
   			$(".focuse").on("touchend",function(e){
   				e.preventDefault();
   				taskAmount();
				setTimeout(function(){
					if (back) {
   					mask();
   				} else{
   					var isFocus=confirm("今日关注任务额度已完成,继续关注将不会获得奖励");
   					if(isFocus){
   						mask();
   					}
   				}
				},0);
   				

   			})
   		};
   		function closeTips(){
   			$(".nonknow").on("touchend",function(e){
   				$(".mask").hide();
				$(".notComplete").hide()
				e.preventDefault();
				var weChatName=responseData.weChatName;
				console.log("公众号："+weChatName);
				var data={
					weChatName:weChatName
				}
				console.log(data);
				var callBack=function(mess){
					alert(mess.msg)
				};
				
				var u = navigator.userAgent;
			    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
			    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
			    console.log('isAndroid:'+isAndroid);
			    console.log("isIOS:"+isIOS);
			    if (isAndroid) {
			    	xampp.copyXiaoMai(JSON.stringify(data),callBack);
			    } else{
			    	copyXiaoMai(JSON.stringify(data),callBack);
			    }
			    
					
				
   			})
   		};
   		function getUrlValue(){
   				var res=location.search.toLowerCase();
				var qs = (res.length>0?res.substring(1):""),
				args={},
				items = qs.length?qs.split("&"):[],
				item = null,
				name = null,
				value = null,
				i=0,
				len = items.length;
				for(i=0;i<len;i++){
					item = items[i].split("=");
					name = decodeURIComponent(item[0]);
					value = decodeURIComponent(item[1]);
					if(name.length){
						args[name] = value;
					}
				}
//				console.log(args)
				return args;
			};
   		function acquireDate(){
   			var params=getUrlValue();
   			console.log("params："+params.taskid);			
   		
   			$.ajax({
   				type:"get",
// 				url:"focusOn.json",
   				url:"/appApi/subscribeWeChatInfo",
   				data:{userId:params.userid,taskId:params.taskid},
   				async:false,
   				success:function(response){
   					responseData=response.data.weChat;
// 					console.log(response);
   					$(".header img").attr("src",responseData.imgUrl);
   					$(".content .title").text(responseData.taskName);
   					$(".notComplete .name").text(responseData.taskName);
   					
   					
   					if (responseData.rewardType==1) {//1表示积分
   						
   						$(".zan .likes").text(responseData.rewardAmount+"积分");
   					}else{//0表示元
   						$(".zan .likes").text(parseInt(responseData.rewardAmount)/100+"元");
   					}
   					
   					$(".source .time").text(responseData.weChatName);
   					
   					$(".content .abstract").text(responseData.introduction);
   					$(".taskDetail").text(responseData.taskDetail)
   					
   					
   				}
   			});
   		};
// 		setTimeout(function(){
// 		console.log(responseData)
// 			
// 		},0)

		
   		setWidth();
   		clickFocus();
   		closeTips();
   		acquireDate();
// 		taskAmount();
   		
	</script>
</html>
